home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
lang
/
fpc09905c.lha
/
fpc
/
units
/
sysamiga.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1998-09-21
|
56KB
|
1,876 lines
{
$Id: sysamiga.pas,v 1.9 1998/08/17 12:34:22 carl Exp $
This file is part of the Free Pascal run time library.
Copyright (c) 1993,98 by Carl Eric Codere
Some parts taken from
Marcel Timmermans - Modula 2 Compiler
Nils Sjoholm - Amiga porter
Matthew Dillon - Dice C (with his kind permission)
dillon@backplane.com
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
unit sysamiga;
{--------------------------------------------------------------------}
{ LEFT TO DO: }
{--------------------------------------------------------------------}
{ o GetDir with different drive numbers }
{--------------------------------------------------------------------}
{$I os.inc}
{ AmigaOS uses character #10 as eoln only }
{$DEFINE SHORT_LINEBREAK}
interface
{ used for single computations }
const BIAS4 = $7f-1;
{$I systemh.inc}
{$I heaph.inc}
const
UnusedHandle : longint = -1;
StdInputHandle : longint = 0;
StdOutputHandle : longint = 0;
StdErrorHandle : longint = 0;
_ExecBase:longint = $4;
_WorkbenchMsg : longint = 0;
_IntuitionBase : pointer = nil; { intuition library pointer }
_DosBase : pointer = nil; { DOS library pointer }
_UtilityBase : pointer = nil; { utiity library pointer }
{ Required for crt unit }
function do_read(h,addr,len : longint) : longint;
function do_write(h,addr,len : longint) : longint;
implementation
const
intuitionname : pchar = 'intuition.library';
dosname : pchar = 'dos.library';
utilityname : pchar = 'utility.library';
argc : longint = 0;
{ AmigaOS does not autoamtically deallocate memory on program termination }
{ therefore we have to handle this manually. This is a list of allocated }
{ pointers from the OS, we cannot use a linked list, because the linked }
{ list itself uses the HEAP! }
pointerlist : array[1..8] of longint =
(0,0,0,0,0,0,0,0);
{$I exec.inc}
TYPE
TDateStamp = packed record
ds_Days : Longint; { Number of days since Jan. 1, 1978 }
ds_Minute : Longint; { Number of minutes past midnight }
ds_Tick : Longint; { Number of ticks past minute }
end;
PDateStamp = ^TDateStamp;
PFileInfoBlock = ^TfileInfoBlock;
TFileInfoBlock = packed record
fib_DiskKey : Longint;
fib_DirEntryType : Longint;
{ Type of Directory. If < 0, then a plain file.
If > 0 a directory }
fib_FileName : Array [0..107] of Char;
{ Null terminated. Max 30 chars used for now }
fib_Protection : Longint;
{ bit mask of protection, rwxd are 3-0. }
fib_EntryType : Longint;
fib_Size : Longint; { Number of bytes in file }
fib_NumBlocks : Longint; { Number of blocks in file }
fib_Date : TDateStamp; { Date file last changed }
fib_Comment : Array [0..79] of Char;
{ Null terminated comment associated with file }
fib_Reserved : Array [0..35] of Char;
end;
TProcess = packed record
pr_Task : TTask;
pr_MsgPort : TMsgPort; { This is BPTR address from DOS functions }
{126} pr_Pad : Word; { Remaining variables on 4 byte boundaries }
{128} pr_SegList : Pointer; { Array of seg lists used by this process }
{132} pr_StackSize : Longint; { Size of process stack in bytes }
{136} pr_GlobVec : Pointer; { Global vector for this process (BCPL) }
{140} pr_TaskNum : Longint; { CLI task number of zero if not a CLI }
{144} pr_StackBase : BPTR; { Ptr to high memory end of process stack }
{148} pr_Result2 : Longint; { Value of secondary result from last call }
{152} pr_CurrentDir : BPTR; { Lock associated with current directory }
{156} pr_CIS : BPTR; { Current CLI Input Stream }
{160} pr_COS : BPTR; { Current CLI Output Stream }
{164} pr_ConsoleTask : Pointer; { Console handler process for current window}
{168} pr_FileSystemTask : Pointer; { File handler process for current drive }
{172} pr_CLI : BPTR; { pointer to ConsoleLineInterpreter }
pr_ReturnAddr : Pointer; { pointer to previous stack frame }
pr_PktWait : Pointer; { Function to be called when awaiting msg }
pr_WindowPtr : Pointer; { Window for error printing }
{ following definitions are new with 2.0 }
pr_HomeDir : BPTR; { Home directory of executing program }
pr_Flags : Longint; { flags telling dos about process }
pr_ExitCode : Pointer; { code to call on exit of program OR NULL }
pr_ExitData : Longint; { Passed as an argument to pr_ExitCode. }
pr_Arguments : PChar; { Arguments passed to the process at start }
pr_LocalVars : TMinList; { Local environment variables }
pr_ShellPrivate : Longint; { for the use of the current shell }
pr_CES : BPTR; { Error stream - IF NULL, use pr_COS }
end;
PProcess = ^TProcess;
{ AmigaOS does not automatically close opened files on exit back to }
{ the operating system, therefore as a precuation we close all files }
{ manually on exit. }
PFileList = ^TFileList;
TFileList = record { no packed, must be correctly aligned }
Handle: longint; { Handle to file }
next: pfilelist; { Next file in list }
closed: boolean; { TRUE=file already closed }
end;
Const
CTRL_C = 20; { Error code on CTRL-C press }
SIGBREAKF_CTRL_C = $1000; { CTRL-C signal flags }
_LVOFindTask = -294;
_LVOWaitPort = -384;
_LVOGetMsg = -372;
_LVOOpenLibrary = -552;
_LVOCloseLibrary = -414;
_LVOClose = -36;
_LVOOpen = -30;
_LVOIoErr = -132;
_LVOSeek = -66;
_LVODeleteFile = -72;
_LVORename = -78;
_LVOWrite = -48;
_LVORead = -42;
_LVOCreateDir = -120;
_LVOSetCurrentDirName = -558;
_LVOGetCurrentDirName = -564;
_LVOInput = -54;
_LVOOutput = -60;
_LVOUnLock = -90;
_LVOLock = -84;
_LVOCurrentDir = -126;
_LVONameFromLock = -402;
_LVONameFromFH = -408;
_LVOGetProgramName = -576;
_LVOGetProgramDir = -600;
_LVODupLock = -96;
_LVOExamine = -102;
_LVOParentDir = -210;
_LVOSetFileSize = -456;
_LVOSetSignal = -306;
_LVOAllocVec = -684;
_LVOFreeVec = -690;
{ Errors from IoErr(), etc. }
ERROR_NO_FREE_STORE = 103;
ERROR_TASK_TABLE_FULL = 105;
ERROR_BAD_TEMPLATE = 114;
ERROR_BAD_NUMBER = 115;
ERROR_REQUIRED_ARG_MISSING = 116;
ERROR_KEY_NEEDS_ARG = 117;
ERROR_TOO_MANY_ARGS = 118;
ERROR_UNMATCHED_QUOTES = 119;
ERROR_LINE_TOO_LONG = 120;
ERROR_FILE_NOT_OBJECT = 121;
ERROR_INVALID_RESIDENT_LIBRARY = 122;
ERROR_NO_DEFAULT_DIR = 201;
ERROR_OBJECT_IN